package com.dhy.canal.util;


import com.google.common.base.CaseFormat;

/**
 * @author zdh
 */
public class StringUtil {
    /**
     * 首字母小写
     *
     * @param str 需要转化的字符串
     */
    public static String firstCharToLower(String str) {
        if(Character.isLowerCase(str.charAt(0))) {
            return str;
        }
        return Character.toLowerCase(str.charAt(0)) + str.substring(1);
    }

    /**
     * 下划线转驼峰: test_data ---> testData
     */
    public static  String underlineToCamel(String underlineStr){
        return CaseFormat.LOWER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL, underlineStr);
    }

    /**
     * 驼峰转下划线: testData ---> test_data
     */
    public static  String camelToUnderline(String camelStr){
        return CaseFormat.LOWER_CAMEL.to(CaseFormat.LOWER_UNDERSCORE, camelStr);
    }
}
